<template>
  <a-modal :open="open" width="680px" title="参数" centered @cancel="onCancel">
    <a-form :model="formState" class="form-style-flex" :label-col="{ style: { width: '120px' } }">
      <a-form-item label="" class="w-full">
        <div class="flex justify-between items-center">
          <span>发送JSON</span>
          <a-button v-copy="formState.inputparameter || ''" type="link" class="px-0">复制</a-button>
        </div>
        <a-textarea v-model:value="formState.inputparameter" :rows="5" placeholder="请输入" />
      </a-form-item>
      <a-form-item label="" class="w-full">
        <div class="flex justify-between items-center">
          <span>返回JSON</span>
          <a-button v-copy="formState.outputparameter" type="link" class="px-0">复制</a-button>
        </div>
        <a-textarea v-model:value="formState.outputparameter" :rows="5" placeholder="请输入" />
      </a-form-item>
    </a-form>
    <template #footer>
      <a-button key="submit" type="primary" @click="onOk">关闭</a-button>
    </template>
  </a-modal>
</template>
<script setup>
import { ref, watch } from 'vue'

const emit = defineEmits(['update:open', 'ok'])
const props = defineProps({
  open: {
    type: Boolean,
    default: false
  },
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const formState = ref({})
watch(
  () => props.open,
  (val) => {
    if (val) {
      if (props.rowData?.id) formState.value = props.rowData
    }
  }
)
const onCancel = () => {
  emit('update:open', false)
  formState.value = {}
}
const onOk = async () => {
  onCancel()
}
</script>
